<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="urun" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{urunHome.managed ? 'Edit' : 'Add'} Urun</f:facet>

            <s:decorate id="urunnoField" template="layout/edit.xhtml">
                <ui:define name="label">Urunno</ui:define>
                <h:inputText id="urunno" cols="80" rows="3" required="true" value="#{urunHome.instance.urunno}"/>
            </s:decorate>

            <s:decorate id="adiField" template="layout/edit.xhtml">
                <ui:define name="label">Adi</ui:define>
                <h:inputText id="adi" cols="80" rows="10" required="true" value="#{urunHome.instance.adi}"/>
            </s:decorate>

            <s:decorate id="ambalajField" template="layout/edit.xhtml">
                <ui:define name="label">Ambalaj</ui:define>
                <h:inputText id="ambalaj" cols="80" rows="10" value="#{urunHome.instance.ambalaj}"/>
            </s:decorate>

            <s:decorate id="barkodField" template="layout/edit.xhtml">
                <ui:define name="label">Barkod</ui:define>
                <h:inputText id="barkod" cols="80" rows="3" value="#{urunHome.instance.barkod}"/>
            </s:decorate>

            <s:decorate id="upcField" template="layout/edit.xhtml">
                <ui:define name="label">Upc</ui:define>
                <h:inputText id="upc" cols="80" rows="3" value="#{urunHome.instance.upc}"/>
            </s:decorate>
            
            <s:decorate id="paletadediField" template="layout/edit.xhtml">
                <ui:define name="label">Paletadedi</ui:define>
                <h:inputText id="paletadedi" cols="80" rows="3" value="#{urunHome.instance.paletadedi}"/>
            </s:decorate>

            <s:decorate id="kalipField" template="layout/edit.xhtml">
                <ui:define name="label">Kalıp</ui:define>
		      	<h:selectOneMenu  width="250" value="#{urunHome.instance.kalip}" required="true">
					<s:selectItems value="#{kalipList.resultList}" var="kalip" label="#{kalip.kod} - #{kalip.ad}" noSelectionLabel="Seçim Yapınız!"  />
					<s:convertEntity />
				</h:selectOneMenu>
			</s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{urunHome.persist}"
                       rendered="#{!urunHome.managed}"/>
<!--                       disabled="#{!urunHome.wired}"-->

            <h:commandButton id="update"
                          value="Save"
                         action="#{urunHome.update}"
                       rendered="#{urunHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{urunHome.remove}"
                      immediate="true"
                       rendered="#{urunHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Urun.xhtml"
                rendered="#{urunHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty urunFrom ? 'UrunList' : urunFrom}.xhtml"
                rendered="#{!urunHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Firma *" labelClass="required" rendered="#{urunHome.instance.firma == null || authenticator.isAdmin()}">
    <div class="association" id="firmaParent">

        <h:outputText value="There is no firma associated with this urun."
                   rendered="#{urunHome.instance.firma == null}"/>

        <rich:dataTable var="_firma"
                   value="#{urunHome.instance.firma}"
                rendered="#{urunHome.instance.firma != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="firmaTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_firma.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ad</f:facet>
                <h:outputText value="#{_firma.ad}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Adres</f:facet>
                <h:outputText value="#{_firma.adres}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Eposta</f:facet>
                <h:outputText value="#{_firma.eposta}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Kod</f:facet>
                <h:outputText value="#{_firma.kod}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Mersisno</f:facet>
                <h:outputText value="#{_firma.mersisno}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Telefon</f:facet>
                <h:outputText value="#{_firma.telefon}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Vergino</f:facet>
                <h:outputText value="#{_firma.vergino}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Webadresi</f:facet>
                <h:outputText value="#{_firma.webadresi}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{urunHome.instance.firma != null ? 'changeParent' : 'selectParent'}" value="#{urunHome.instance.firma != null ? 'Change' : 'Select'} firma"
                       view="/FirmaList.xhtml">
                <f:param name="from" value="UrunEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Kalip *" labelClass="required" rendered="#{authenticator.isAdmin()}">
    <div class="association" id="kalipParent">

        <h:outputText value="There is no kalip associated with this urun."
                   rendered="#{urunHome.instance.kalip == null}"/>

        <rich:dataTable var="_kalip"
                   value="#{urunHome.instance.kalip}"
                rendered="#{urunHome.instance.kalip != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="kalipTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_kalip.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Ad</f:facet>
                <h:outputText value="#{_kalip.ad}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Agirlik</f:facet>
                <h:outputText value="#{_kalip.agirlik}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Firma id</f:facet>
                <h:outputText value="#{_kalip.firma.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Kod</f:facet>
                <h:outputText value="#{_kalip.kod}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Olcubirim id</f:facet>
                <h:outputText value="#{_kalip.olcubirim.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Setmi</f:facet>
                <h:outputText value="#{_kalip.setmi}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{urunHome.instance.kalip != null ? 'changeParent_2' : 'selectParent_2'}" value="#{urunHome.instance.kalip != null ? 'Change' : 'Select'} kalip"
                       view="/KalipList.xhtml">
                <f:param name="from" value="UrunEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
